﻿using Windows.ApplicationModel.Search;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

// “用户控件”项模板在 http://go.microsoft.com/fwlink/?LinkId=234236 上提供

namespace XnReader.WinRT
{
    public sealed partial class ToolBar
    {
        public delegate void ButtonEventHandler(object sender, RoutedEventArgs e);

        public event ButtonEventHandler DelStoreClickEvent;
        public event ButtonEventHandler AddStoreClickEvent;
        public event ButtonEventHandler BookReaderClickEvent;
        public event ButtonEventHandler SettingClickEvent;
        public event ButtonEventHandler RefreshClickEvent;

        public ToolBar()
        {
            InitializeComponent();
        }

        private void ButtonClick(object sender, RoutedEventArgs e)
        {
            var button = sender as Button;
            if (button != null)
            {
                switch (button.Name)
                {
                    case "btnSearch":
                        {
                            SearchPane.GetForCurrentView().Show();
                        }
                        break;
                    case "btnRefresh":
                        {
                            if (RefreshClickEvent != null)
                                RefreshClickEvent(this, e);
                        }
                        break;
                    case "btnDelStore":
                        {
                            if (DelStoreClickEvent != null)
                            {
                                DelStoreClickEvent(sender, e);
                            }
                        }
                        break;
                    case "btnAddStore":
                        {
                            if (AddStoreClickEvent != null)
                            {
                                AddStoreClickEvent(sender, e);
                            }
                        }
                        break;
                    case "btnBookReader":
                        {
                            if (BookReaderClickEvent != null)
                            {
                                BookReaderClickEvent(sender, e);
                            }
                        }
                        break;
                    case "btnSetting":
                        {
                            if (SettingClickEvent != null)
                            {
                                SettingClickEvent(sender, e);
                            }
                        }
                        break;
                    case "btnRights":
                        {
                            var rootFrame = Window.Current.Content as Frame;
                            if (rootFrame != null) rootFrame.Navigate(typeof(Rights));
                        }
                        break;
                    case "btnProtocol":
                        {
                            var rootFrame = Window.Current.Content as Frame;
                            if (rootFrame != null) rootFrame.Navigate(typeof(Protocol));
                        }
                        break;
                    case "btnContactUs":
                        {
                            var rootFrame = Window.Current.Content as Frame;
                            if (rootFrame != null) rootFrame.Navigate(typeof(Link));
                        }
                        break;
                }
            }
        }
    }

    public class ToolBarInfo
    {
        private Visibility _visibleSearch= Visibility.Collapsed;

        public Visibility VisibleSearch
        {
            get { return _visibleSearch; }
            set { _visibleSearch = value; }
        }

        private Visibility _visibleRefresh = Visibility.Collapsed;
        public Visibility VisibleRefresh
        {
            get { return _visibleRefresh; }
            set { _visibleRefresh = value; }
        }

        private Visibility _visibleLogin = Visibility.Collapsed;
        public Visibility VisibleLogin
        {
            get { return _visibleLogin; }
            set { _visibleLogin = value; }
        }

        private Visibility _visibleAddStore = Visibility.Collapsed;
        public Visibility VisibleAddStore
        {
            get { return _visibleAddStore; }
            set { _visibleAddStore = value; }
        }

        private Visibility _visibleCommend = Visibility.Collapsed;
        public Visibility VisibleCommend
        {
            get { return _visibleCommend; }
            set { _visibleCommend = value; }
        }

        private Visibility _visibleDelStore = Visibility.Collapsed;
        public Visibility VisibleDelStore
        {
            get { return _visibleDelStore; }
            set { _visibleDelStore = value; }
        }

        private Visibility _visibleBookReader = Visibility.Collapsed;
        public Visibility VisibleBookReader
        {
            get { return _visibleBookReader; }
            set { _visibleBookReader = value; }
        }

        private Visibility _visibleSetting = Visibility.Collapsed;
        public Visibility VisibleSetting
        {
            get { return _visibleSetting; }
            set { _visibleSetting = value; }
        }

        private Visibility _visibleRight = Visibility.Collapsed;
        public Visibility VisibleRights
        {
            get { return _visibleRight; }
            set { _visibleRight = value; }
        }

        private Visibility _visibleContactUs = Visibility.Collapsed;
        public Visibility VisibleContactUs
        {
            get { return _visibleContactUs; }
            set { _visibleContactUs = value; }
        }

        private Visibility _visibleProtocol = Visibility.Collapsed;
        public Visibility VisibleProtocol
        {
            get { return _visibleProtocol; }
            set { _visibleProtocol = value; }
        }

    }
}
